<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" href="../style/journal.css" type="text/css" />
<style type="text/css"><!--
.googleadsense {
	margin: 2px;
	padding: 0px;
//--></style><script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-65008-1";
urchinTracker();
</script><title>Graph::Easy</title>
</head>
<body>
<a href="index.html">Journal</a>(2005) | <a href="../blog/"><b>Blog</b></a>(2006) | <a href="http://www.fayland.org/cgi-bin/random_link.pl">RandomLink</a> | <a href="AboutFayland.html">WhoAmI</a> | <a href="LiveBookmark.html">LiveBookmark</a> | <a href="http://www.fayland.org/">HomePage</a>
<p><&lt;Previous: <a href="template_introduction.html">Template Toolkit 入门</a>&nbsp;&nbsp;>>Next: <a href="Feedburner.html">using FeedBurner</a></p>
<h1>Graph::Easy</h1>
<div class='content'>
<p>Category: <a href='Modules.html'>Modules</a> &nbsp; Keywords: <b>Graph::Easy</b></p>最初认识这模块是 <a href="http://www.livejournal.com/users/joe_jiang/">joe jiang</a> 用的时候。他用这个模块做了一些很有用的图。<br />后来在 use.perl 上也看到几个人用这个做 <a href="http://search.cpan.org/perldoc?DBIx::Class">DBIx::Class</a> 的关系图。觉得挺不错的。<br />今天拿来做做 svk 的关系图。发现做一个简单的图很简单。复杂的图应该也比较简单，不过还没试验过。<br />因为在 Win32 下跑，所以也没安装 'gpg'. <p />因为很简单，所以代码也很简单：<br /><pre>#!/usr/bin/perl<br />use strict;<br />use warnings;<br />use CGI::Carp qw(fatalsToBrowser);<br />use CGI qw/:cgi/;<p />my $query = new CGI;<br />print $query->header(-type=>'text/html');<p />use Graph::Easy;<p />my $graph = Graph::Easy->new();<p />my $remote = $graph->add_node("Remote\n(SVN server)");<br />my $mirror = $graph->add_node("Mirror\n(Local Machine)");<br />my $local  = $graph->add_node('Local Machine');<p /># sync<br />my $edge = Graph::Easy::Edge->new( label => 'sync' );<br />$graph->add_edge ($remote, $mirror, $edge);<br /># checkout, up, ci<br />$edge = Graph::Easy::Edge->new( label => 'co' );<br />$graph->add_edge ($mirror, $local, $edge);<br />$edge = Graph::Easy::Edge->new( label => 'up' );<br />$graph->add_edge ($mirror, $local, $edge);<br />$edge = Graph::Easy::Edge->new( label => 'ci' );<br />$graph->add_edge ($mirror, $local, $edge);<br /># log, diff<br />$edge = Graph::Easy::Edge->new( label => 'log' );<br />$graph->add_edge ($mirror, $local, $edge);<br />$edge = Graph::Easy::Edge->new( label => 'diff' );<br />$graph->add_edge ($mirror, $local, $edge);<p /># raw HTML section<br />#print $graph->as_html_file( );<br />#my $graphviz = $graph->as_graphviz();</pre>用 Graphviz 弄出来的结果大致是这样子的：<br /><img src='img/graph_easy.png' alt='graph easy' /><h4>Update</h4>Win32 下的 Graphviz 在 <a href="http://www.graphviz.org/Download_windows.php">http://www.graphviz.org/Download_windows.php</a> 可以下。</div>
<p><&lt;Previous: <a href="template_introduction.html">Template Toolkit 入门</a>&nbsp;&nbsp;>>Next: <a href="Feedburner.html">using FeedBurner</a></p>
<p><strong>Options:</strong> <a href='http://del.icio.us/post?title=Graph::Easy&url=http://www.fayland.org/journal/Graph_Easy.html'>+Del.icio.us</a></p>
<strong>Related items</strong>
<ul><li><a href='Template_Configuration.html'>Template Toolkit 的配置选项</a> < <span class='digit'>2005-10-24 20:23:23</span> ></li><li><a href='template_introduction.html'>Template Toolkit 入门</a> < <span class='digit'>2005-12-03 18:15:26</span> ></li><li><a href='Template_builtin_Filters.html'>Template builtin Filters</a> < <span class='digit'>2005-12-09 23:14:04</span> ></li><li><a href='Template_customized_Filte.html'>Template customized Filters</a> < <span class='digit'>2005-12-10 01:10:15</span> ></li><li><a href='Accessing_External_TTFile.html'>导入 Template Toolkit 文件</a> < <span class='digit'>2005-12-10 22:42:16</span> ></li><li><a href='EmailWithAttachment.html'>发送邮件附件</a> < <span class='digit'>2005-03-23 22:18:40</span> ></li><li><a href='Perl6_Rules.html'>用 Perl6::Rules 来写 Formatter</a> < <span class='digit'>2005-09-27 10:02:45</span> ></li><li><a href='modperl_http_cycle.html'>modperl 服务器的运行阶段和句柄</a> < <span class='digit'>2005-11-22 15:33:08</span> ></li><li><a href='attributes.html'>attributes 用法介绍</a> < <span class='digit'>2005-12-01 00:03:06</span> ></li></ul>
Created on <span class="digit">2005-12-07 10:35:07</span>, Last modified on <span class="digit">2005-12-07 22:24:12</span><br />
Copyright 2004-2005 All Rights Reserved. Powered by <a href="Eplanet.html">Eplanet</a> && <a href='http://catalyst.perl.org'>Catalyst</a> 5.62.
</body>
</html>